<?php
/**
 * Created by PhpStorm.
 * User: fantaixi
 * Date: 2018/5/4
 * Time: 16:09
 */

namespace app\admin\controller;

use app\common\attr;


class AttrBase extends Base
{
    public $type;
    public $title;
    public function __construct()
    {
        parent::__construct();

    }

    public function attr_list()
    {
        $data = attr::get_list($this->type);
        $this->assign('data',$data);
        $this->assign('title',$this->title);
        return $this->fetch('attr/index');
    }

    public function ajax_add_attr()
    {
        $a = attr::add($this->type);
        if($a){
            echo api_return(1,'保存成功');
        }else{
            echo api_return(0,'保存失败');
        }
    }

    public function ajax_update_attr()
    {
        $a = attr::update();
        if($a){
            echo api_return(1,'保存成功');
        }else{
            echo api_return(0,'保存失败');
        }
    }

    public function ajax_del_attr()
    {
        $a = attr::del();
        if($a){
            echo api_return(1,'删除成功');
        }else{
            echo api_return(0,'删除失败');
        }
    }

}